# Maintainer: Tim Meusel <tim@bastelfreak.de>
# Contributor: Achilleas Pipinellis <axilleas at archlinux.info>
# Contributor: Hyacinthe Cartiaux <hyacinthe.cartiaux (a) free.fr>
# Contributor: gem2arch 0.1

_gemname='net-ssh'
pkgname="ruby-${_gemname}"
pkgver=7.0.1
pkgrel=1
pkgdesc='A pure-Ruby implementation of the SSH2 client protocol.'
arch=('any')
url='https://github.com/net-ssh/net-ssh'
license=('MIT')
depends=('ruby' 'ruby-ed25519' 'ruby-x25519' 'ruby-bcrypt_pbkdf')
makedepends=('ruby-rake' 'ruby-bundler' 'ruby-rdoc')
checkdepends=('ruby-minitest' 'ruby-mocha')
options=('!emptydirs')
source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz")
sha512sums=('3e41537b3b7e34f043c768959c382f72a630bf3ac430bbbd743323d9b0eade6c7b94f8948418b7f3e1aa2422fcb87829387aaa01e1e384ed297e2397cee33feb')

prepare() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  sed -E 's|~>|>=|g' -i ${_gemname}.gemspec
  sed --in-place 's|`git ls-files -z`|`find . -print0`|' "${_gemname}.gemspec"

  # purge development dependencies
  sed --in-place '/spec.add_development_dependency/d' "${_gemname}.gemspec"
}

build() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  gem build ${_gemname}.gemspec
}

check() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  rake test
}

package() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  local _gemdir="$(gem env gemdir)"
  gem install --ignore-dependencies --no-user-install -i "${pkgdir}${_gemdir}" -n "${pkgdir}/usr/bin" ${_gemname}-${pkgver}.gem
  install -Dm 644 README.md CHANGES.txt THANKS.txt net-ssh-public_cert.pem -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
  rm "${pkgdir}/${_gemdir}/cache/${_gemname}-${pkgver}.gem"
}

# vim: ts=2 sw=2 et:
